home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / LogonFrame.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-01-30  |  3.4 KB  |  115 lines

  1. package symantec.itools.db.awt;
  2.  
  3. import java.awt.Button;
  4. import java.awt.Component;
  5. import java.awt.Container;
  6. import java.awt.Event;
  7. import java.awt.Frame;
  8. import java.awt.Label;
  9. import java.awt.LayoutManager;
  10. import java.awt.TextField;
  11. import symantec.itools.db.pro.ConnectionInfo;
  12. import symantec.itools.db.pro.Logon;
  13.  
  14. public class LogonFrame extends Frame implements Logon {
  15.    // $FF: renamed from: OK java.awt.Button
  16.    Button field_0;
  17.    Button Cancel;
  18.    TextField UserNameEdit;
  19.    TextField UserPasswordEdit;
  20.    Label label3;
  21.    Label label4;
  22.    Label datasource;
  23.    Label datasource1;
  24.    ConnectionInfo m_ConnectionInfo;
  25.    boolean m_Action;
  26.  
  27.    public LogonFrame() {
  28.       super("LogonFrame window");
  29.       ((Container)this).setLayout((LayoutManager)null);
  30.       ((Frame)this).addNotify();
  31.       ((Component)this).resize(((Container)this).insets().left + ((Container)this).insets().right + 501, ((Container)this).insets().top + ((Container)this).insets().bottom + 219);
  32.       this.field_0 = new Button("OK");
  33.       ((Container)this).add(this.field_0);
  34.       this.field_0.reshape(((Container)this).insets().left + 385, ((Container)this).insets().top + 7, 91, 30);
  35.       this.Cancel = new Button("Cancel");
  36.       ((Container)this).add(this.Cancel);
  37.       this.Cancel.reshape(((Container)this).insets().left + 385, ((Container)this).insets().top + 45, 91, 30);
  38.       this.UserNameEdit = new symantec.itools.db.awt.TextField(28);
  39.       ((Container)this).add(this.UserNameEdit);
  40.       this.UserNameEdit.reshape(((Container)this).insets().left + 133, ((Container)this).insets().top + 112, 238, 23);
  41.       this.UserPasswordEdit = new symantec.itools.db.awt.TextField(28);
  42.       this.UserPasswordEdit.setEchoCharacter('*');
  43.       ((Container)this).add(this.UserPasswordEdit);
  44.       this.UserPasswordEdit.reshape(((Container)this).insets().left + 133, ((Container)this).insets().top + 150, 238, 22);
  45.       this.label3 = new Label("UserName");
  46.       ((Container)this).add(this.label3);
  47.       this.label3.reshape(((Container)this).insets().left + 14, ((Container)this).insets().top + 120, 70, 15);
  48.       this.label4 = new Label("Password");
  49.       ((Container)this).add(this.label4);
  50.       this.label4.reshape(((Container)this).insets().left + 14, ((Container)this).insets().top + 157, 70, 15);
  51.       this.datasource = new Label("DataSource Name:");
  52.       ((Container)this).add(this.datasource);
  53.       this.datasource.reshape(((Container)this).insets().left + 14, ((Container)this).insets().top + 15, 133, 15);
  54.       this.datasource1 = new Label("DataSource Name:");
  55.       ((Container)this).add(this.datasource1);
  56.       this.datasource1.reshape(((Container)this).insets().left + 140, ((Container)this).insets().top + 15, 224, 15);
  57.    }
  58.  
  59.    public void show() {
  60.       super.show();
  61.    }
  62.  
  63.    public boolean handleEvent(Event event) {
  64.       if (event.id == 1001 && event.target == this.Cancel) {
  65.          this.clickedCancel();
  66.          return true;
  67.       } else if (event.id == 1001 && event.target == this.field_0) {
  68.          this.clickedOK();
  69.          return true;
  70.       } else if (event.id == 201) {
  71.          ((Component)this).hide();
  72.          return true;
  73.       } else {
  74.          if (event.id == 401 && event.key == 9) {
  75.             if (event.target == this.UserNameEdit) {
  76.                this.UserPasswordEdit.requestFocus();
  77.             } else {
  78.                this.UserNameEdit.requestFocus();
  79.             }
  80.          }
  81.  
  82.          return super.handleEvent(event);
  83.       }
  84.    }
  85.  
  86.    public void clickedOK() {
  87.       this.m_ConnectionInfo.setUser(this.UserNameEdit.getText());
  88.       this.m_ConnectionInfo.setPassword(this.UserPasswordEdit.getText());
  89.       this.m_Action = true;
  90.       ((Component)this).hide();
  91.    }
  92.  
  93.    public void clickedCancel() {
  94.       this.m_Action = false;
  95.       ((Component)this).hide();
  96.    }
  97.  
  98.    public boolean logonFailed(ConnectionInfo conn, int retries) {
  99.       this.m_ConnectionInfo = conn;
  100.       this.UserNameEdit.setText(conn.getUser());
  101.       this.UserPasswordEdit.setText(conn.getPassword());
  102.       this.datasource1.setText(conn.getDBString());
  103.       ((Frame)this).setTitle("User Authentication");
  104.       this.show();
  105.  
  106.       while(((Component)this).isVisible()) {
  107.          Thread.currentThread();
  108.          Thread.yield();
  109.       }
  110.  
  111.       conn = this.m_ConnectionInfo;
  112.       return this.m_Action;
  113.    }
  114. }
  115.